<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>ListLookup</title>
<h2>Help Desk Ticket</h2>
</head>
<body>
<script type="text/javascript">
function checkValues(formref, field)
{
	if (formref.id.value != -1)
	{
		var table = formref.lookup.value;
		if ((table == "cost_centre") || (table == "sponsor_cost_center") || (table == "directorate"))
		{
			var old = 'old_'+field;
			// March 2008-ORA-0208_MR-017 - Added condition to restrict alert message for is_selectable.
			if(formref[field].value != formref[old].value)
			{
				var no = window.showModalDialog('/pages/generic_warning.html','','dialogHeight:250px;dialogWidth:350 px;help:no;scroll:no;status:no;');
				if(no)
				{
					formref[field].value = formref[old].value;
					formref[field].focus();
					return false;
				}
				else
				{
					if(checkDelete())
					{
						formref.submit();
					}
					else if(field == "is_current")
					{
						formref.submit();
					}
				}
			}
			else
			{
				if(checkDelete())
				{
					formref.submit();
				}
			}
			// March 2008-ORA-0208_MR-017 - Changes end here.
		}
	}
}

// November 2010-ORA-0731 - Added function to validate "Value" field.
function checkSelected(form)
{
	if(form.value.value == "")
	{
		alert("Value field cannot be empty");
		form.value.focus();
		return false;
	}
	else
	{
		return true;
	}
}

// February 2012-ORA-0963 - Added new function checkDefault.
function checkDefault(formref)
{
	if(formref.value.value == "")
	{
		alert("Value field cannot be empty");
		formref.value.focus();
		return false;
	}
	else
	{
		if (formref.is_default.value == 1)
		{
			if ((formref.is_current.value == 0) || (formref.is_selectable.value == 0))
			{
				alert("This is the default value of the lookup. Please change the default value before making this non selectable or not current.");
				if (formref.is_current.value == 0)
				{
					formref.is_current.focus();
				}
				else
				{
					formref.is_selectable.focus();
				}
				return false;
			}
		}
	}
}
</script>

<s:form action="HelpDeskTicket">
<table>
<tr><s:textfield name="problem" label = "Problem Summary" id="myinput" size="30"/></tr>
<input type="submit" name="submit1" value="Save" onClick = "return checkDefault(this.form,'is_current','is_selectable');return checkSelected(this.form);return checkValues(this.form, 'value');">
</table>
    <s:submit name = "commandButton" id="mysubmit" value="Submit Claim" align="center" />
</s:form>
</body>
</html>


